package com.my.object;

import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

@Entity
@Table(name = "student")
public class Student {
	@Id
	@Column(name = "id")
	private int id;
	@Column(name = "sid")
	private int sid;
	@Column(name = "firstname")
	private String firstname;
	@Column(name = "lastname")
	private String lastname;
	@Column(name = "gender")
	private String gender;
	@Column(name = "phone")
	private String phone;
	@Column(name = "email")
	private String email;
	@Column(name = "date_of_birth")
	private String dateOfBirth;

	@OneToOne(cascade = CascadeType.ALL)
	@PrimaryKeyJoinColumn
	private StudentLogin login;

	@OneToMany
	@JoinColumn(name = "student_id")
	private Set<Registeration> registeration;

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "student_status_id")
	private StudentStatus status;

	public Set<Registeration> getRegisteration() {
		return registeration;
	}

	public void setRegisteration(Set<Registeration> registeration) {
		this.registeration = registeration;
	}

	public StudentStatus getStatus() {
		return status;
	}

	public void setStatus(StudentStatus status) {
		this.status = status;
	}

	public String getDateOfBirth() {
		return dateOfBirth;
	}

	public void setDateOfBirth(String dateOfBirth) {
		this.dateOfBirth = dateOfBirth;
	}

	public StudentLogin getLogin() {
		return login;
	}

	public void setLogin(StudentLogin login) {
		this.login = login;
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public int getSid() {
		return sid;
	}

	public void setSid(int sid) {
		this.sid = sid;
	}

	public String getFirstname() {
		return firstname;
	}

	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}

	public String getLastname() {
		return lastname;
	}

	public void setLastname(String lastname) {
		this.lastname = lastname;
	}

	public String getGender() {
		return gender;
	}

	public void setGender(String gender) {
		this.gender = gender;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getDataOfBirth() {
		return dateOfBirth;
	}

	public void setDataOfBirth(String dataOfBirth) {
		this.dateOfBirth = dataOfBirth;
	}

	@Override
	public String toString() {
		return "[id=" + id + ", sid=" + sid + ", firstname=" + firstname
				+ ", lastname=" + lastname + ", gender=" + gender + ", phone="
				+ phone + ", email=" + email + ", dataOfBirth=" + dateOfBirth
				+ "student_status=" + status.getCode() + "]";
	}

}
